
public class Multime implements Structura {
	protected int[] multime;
	private static int i;
	private static int max;
	
	
	public Multime()
	{
		i=0;
		max=10;
		multime=new int[10];
	}
	
	
	public Multime(int dimensiune)
	{
		i=0;
		max=dimensiune;
		multime=new int[dimensiune];
	}
	
	
	private int[] getMultime()
	{
		return this.multime;
	}
	
	
	private void setMultime(int[] m)
	{
	int n=m.length;
    for(int i=0;i<n;i++)
	   {
	   	this.multime[i]=m[i];
	   }
	    
	}
	
	
	public void adauga(int elem)
	{
	if(i<max)
	{
	multime[i]=elem;
	i=i+1;
	}
	else
	{		System.out.println("Multimea este plina, nu se poate adauga elementul "+elem);
	}
		
	}
	public void sterge(int elem)
	{
	int i=0;
	int[] aux=new int[max];
	int iAux=0;
	int nrAparitii=0;
	while(i<i)
	{
		if(this.multime[i]!=elem)
		{
		  	aux[iAux]=this.multime[i];
		  	iAux++;
		}
		else
		{
			nrAparitii++;
		}
		i++;
	}
	this.setMultime(aux);
	i=i-nrAparitii;
	
	}
	
	private boolean apartine(int []m, int elem)
	{
	int i=0;
	boolean gasit=false;
	while((i<m.length)&&(gasit==false))
	{
		if(m[i]==elem)
		{
			gasit=true;
		}
		else
		{
			i++;
		}
	}
	return gasit;
	
	}
	public void reuniune(int[] m)
	{
	int aux[]=new int[max];
	int i=0;
	for(i=0;i<i;i++)
	{
		aux[i]=this.multime[i];
	}
	int nrEl=0;
	for(int j=0;j<m.length;j++)
	{
	   boolean gasit=this.apartine(aux,m[j]);
	   if(gasit==false)
	   {
		   aux[i]=m[j];
		   i++;
		   nrEl++;
	   }
		   
	}
	this.setMultime(aux);
	i=i+nrEl;
}

	public void afiseaza()
	{
	if(i>0)
	{
	System.out.print("Multimea:{");
	for(int i=0;i<i-1;i++)
	{
		System.out.print(this.multime[i]+",");
	}
	System.out.println(this.multime[i-1]+"}");
	}
	else
	{
		System.out.println("Multimea este vida");
	}
	}
}